class Node:
    def __init__(self,item):
        self.item = item
        self.next = None

    def __repr__(self):
        return str(self.item)


# 头插法 创建链表
def Hcrweate_linklist(li):
    head = Node(li[0])
    for element in li[1:]:
        node = Node(element)
        node.next = head
        head = node
    return head


# 尾插法 创建链表
def Tcrweate_linklist(li):
    head = Node(li[0])
    tail = head
    for element in li[1:]:
        node = Node(element)
        tail.next = node
        tail = node
    return head    

def print_linklist(li):
    turn = li
    while turn:
        print(turn.item, end=" ")
        turn = turn.next
    print()





if __name__ == "__main__":
    lk = Tcrweate_linklist([1,2,3,4])
    print_linklist(lk)




    print_linklist(lk)
